import { useEffect, useState } from 'react';
import Render from './Render';
import newStr from './newStr';
import oldStr from './oldStr';
import { createPatch } from 'diff';

// import jsDiff from 'diff';
const jsDiff = require('diff');
import './index.less';

export default () => {
    const [diffArr, setDiffArr] = useState([]);

    useEffect(() => {
        const a = jsDiff.diffLines(oldStr, newStr);
        const diffStr = createPatch('1', oldStr, newStr);
        debugger;
        setDiffArr(a);
    }, []);

    return (
        <div className="diff-test">
            <Render diffArr={diffArr} />
        </div>
    );
};
